import { Radio, Space, Typography } from 'antd'
import React from 'react'
import { QuestionRadioDefaultProps, QuestionRadioPropsType } from './interface'

const Component: React.FC<QuestionRadioPropsType> = props => {
  const {
    title = '',
    isVertical = false,
    options,
    defaultValue,
  } = { ...QuestionRadioDefaultProps, ...props }

  return (
    <div>
      <Typography.Paragraph strong>{title}</Typography.Paragraph>
      <Radio.Group value={defaultValue}>
        <Space direction={isVertical ? 'vertical' : 'horizontal'}>
          {options?.map(({ value, text }) => {
            return (
              <Radio key={value} value={value}>
                {text}
              </Radio>
            )
          })}
        </Space>
      </Radio.Group>
    </div>
  )
}

export default Component
